<template>
  <div class="bussiness-rate el-absolute " :class="[type]">
    <div class="rate-title el-flex el-flex-row el-flex-space-between el-flex-y-center el-py-2">
      <span class="rate-title-text">
        <i class="rate-title-icon el-mr-1"></i>
        业务{{ title }}数量排行
      </span>
      <i class="trigger" :class="{ reverse: !rateShow }" @click="rateShow = !rateShow"></i>
    </div>
    <el-collapse-transition>
      <div class="rate-content" v-show="rateShow">
        <div class="table-head el-flex el-flex-row el-mb-1">
          <div class="head-item el-mr-1">排名</div>
          <div class="head-item el-mr-1">区县</div>
          <div class="head-item num-text">{{ title }}量(件)</div>
        </div>
        <div class="table-body">
          <div class="area-item el-flex el-flex-row el-mb-1" v-for="(area, index) in list" :key="area.szq">
            <div class="table-item el-mr-1" :class="[`rate${index + 1}`]">
              {{ index > 2 ? index + 1 : '' }}
            </div>
            <div class="table-item normal-text el-mr-1">{{ area.szq }}</div>
            <div class="table-item num-text">{{ area.acceptnum || area.finishnum }}</div>
          </div>
        </div>
      </div>
    </el-collapse-transition>
  </div>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
@Component({
  name: 'RatePanel'
})
export default class RatePanel extends Vue {
  @Prop({ default: '' }) type!: string
  @Prop({ default: [] }) list!: any[]
  rateShow = true
  dataSource: any[] = [
    {
      name: '芙蓉区',
      accept: 97,
      done: 93
    },
    {
      name: '天心区',
      accept: 122,
      done: 127
    },
    {
      name: '岳麓区',
      accept: 522,
      done: 374
    },
    {
      name: '开福区',
      accept: 178,
      done: 187
    },
    {
      name: '雨花区',
      accept: 194,
      done: 0
    },
    {
      name: '长沙县',
      accept: 239,
      done: 194
    },
    {
      name: '望城区',
      accept: 164,
      done: 149
    },
    {
      name: '浏阳市',
      accept: 247,
      done: 181
    },
    {
      name: '宁乡市',
      accept: 95,
      done: 85
    }
  ]
  get filtedNumberRate() {
    return this.dataSource.sort((a, b) => b[this.type] - a[this.type]).splice(0, 5)
  }
  get title() {
    return this.type === 'accept' ? '受理' : '办结'
  }
}
</script>
<style scoped lang="scss">
.bussiness-rate {
  &.accept {
    left: 2px;
    top: 2px;
    // width: 336px;
    width: 304px;
  }
  &.done {
    right: 2px;
    bottom: 2px;
    width: 304px;
  }
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(0, 33, 96, 0.75) 0%, rgba(0, 33, 96, 0.35) 100%);
  .rate-title {
    .rate-title-text {
      font-size: 16px;
      text-align: left;
      color: #fff;
      text-shadow: 0 0 4px #006aff;
      .rate-title-icon {
        display: inline-block;
        background: url('~@/assets/cockpit/subdivision/subject.png') center/cover no-repeat;
        width: 24px;
        height: 24px;
        vertical-align: middle;
      }
    }
    .trigger {
      width: 24px;
      height: 24px;
      cursor: pointer;
      background: url('~@/assets/cockpit/subdivision/double-arrow-down.png') center/cover no-repeat;
      transition: all 0.3s;
      &.reverse {
        transform: rotate(180deg);
      }
    }
  }
  .rate-content {
    .table-head {
      .head-item {
        width: 112px;
        line-height: 28px;
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        text-align: center;
        &:first-child {
          width: 70px;
        }
        &.num-text {
          text-align: right;
          padding-right: 20px;
        }
      }
    }
    .table-item {
      line-height: 36px;
      background: rgba(255, 255, 255, 0.05);
      color: #fff;
      &:first-child {
        width: 70px;
        text-align: center;
      }
      &.normal-text {
        font-family: 'PingFang SC';
        font-weight: 400;
        font-size: 12px;
        text-align: center;
        width: 112px;
      }
      &.num-text {
        width: 112px;
        font-family: 'DIN Alternate Bold';
        font-weight: bold;
        font-size: 16px;
        text-align: right;
        padding-right: 20px;
      }
      &.rate1 {
        background-image: url('~@/assets/cockpit/subdivision/129.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: 24px 32px;
      }
      &.rate2 {
        background-image: url('~@/assets/cockpit/subdivision/130.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: 24px 32px;
      }
      &.rate3 {
        background-image: url('~@/assets/cockpit/subdivision/131.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: 24px 32px;
      }
    }
  }
}
</style>
